/*
 * @Description: 
 * @Author: yyh
 * @Date: 2022-03-03 00:13:56
 * @LastEditors: yyh
 * @LastEditTime: 2022-04-06 23:31:32
 */
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter);

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)

}

const routes = [
  {
    path: '/',
    name: "Login",
    component: () => import('@/views/Login.vue')
  },
  {
    path: '/Login',
    name: "Login",
    component: () => import('@/views/Login.vue')
  },
  {
    path: '/Main',
    name: 'Main',
    component: () => import('@/views/Main.vue'),
    children: [
      {
        path: '/Home',
        meta: { requireAuth: true},
        component: () => import('@/views/Home.vue')
      },
      {
        path: '/Classification',
        meta: { requireAuth: true},
        component: () => import('@/views/Classification.vue')
      },
      {
        path: '/Statements',
        meta: { requireAuth: true},
        component: () => import('@/views/Statements.vue')
      },
      {
        path: '/Register',
        meta: { requireAuth: true},
        component: () => import('@/views/Register.vue')
      },
      {
        path: '/AssetList',
        meta: { requireAuth: true},
        component: () => import('@/views/AssetList.vue')
      },
      {
        path: '/Use',
        meta: { requireAuth: true},
        component: () => import('@/views/Use.vue')
      },
      {
        path: '/Borrowing',
        meta: { requireAuth: true},
        component: () => import('@/views/Borrowing.vue')
      },
      {
        path: '/Maintenance',
        meta: { requireAuth: true},
        component: () => import('@/views/Maintenance.vue')
      },
      {
        path: '/Scrap',
        meta: { requireAuth: true},
        component: () => import('@/views/Scrap.vue')
      },
      {
        path: '/User',
        meta: { requireAuth: true, permission: ['超级管理员'] },
        component: () => import('@/views/User.vue')
      },
      {
        path: '/UserInfo',
        meta: { requireAuth: true},
        component: () => import('@/views/UserInfo.vue')
      }
    ]
  },
  // 404 page must be placed at the end !!!
  {
    path: '*',
    component: () => import('@/views/404.vue'),
  },


]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
